<template>
  <div class="regulateResumeItem">
    <div class="wrap" @click="toDetail">
      <div class="top">
        <image class="image" v-if="item.status == 1" src="@/pages2/static/images/zsz.png" mode="widthFix" />
        <image class="image" v-if="item.status == 2" src="@/pages2/static/images/shz.png" mode="widthFix" />
        <image class="image" v-if="item.status == 3" src="@/pages2/static/images/gbzw.png" mode="widthFix" />
        <image class="image" v-if="item.status == 4" src="@/pages2/static/images/shz.png" mode="widthFix" />
        <image class="image" v-if="item.status == 5" src="@/pages2/static/images/shbtg.png" mode="widthFix" />
        <text class="isjj" v-if="item.is_buy_urgent && item.status == 4">已购买加急，审核通过后将直接加急展示该信息</text>
        <!-- <image class="is_urgent" v-if="item.is_urgent && item.status == 1" src="@/pages2/static/images/urgent-icon.png" mode="widthFix" /> -->
        <image webp="true" class="is_urgent" @click="toDetail" src="/pages2/static/images/urgent-icon.png" v-if="item['is_urgent'] && item.status == 1"></image>
      </div>
      <div class="title">{{ $getTitleText(item.job_intention) }}</div>
      <div class="content">{{ item.content }}</div>
      <div class="image_box" v-if="item.picture_url">
        <image @click="preview(index)" :key="index" v-for="(item2, index) in getImages(item.picture_url)" :src="item2" mode="aspectFill" fit="cover" />
      </div>
      <div class="line"></div>
      <div class="bottom">
        <div class="item address">
          <i class="iconfont cyweizhi"></i>
          <text>{{ item.city_list || "暂无地址" }}</text>
        </div>
        <div class="item phone">
          <i class="iconfont cydian_hua"></i>
          <text>{{ item.phone }}</text>
        </div>
        <div class="item name">
          <i class="iconfont cya-1Arenyuanyonghu"></i>
          <text>{{ item.name }}</text>
        </div>
      </div>
    </div>
    <div class="show-time">
      <div class="st-left">
        <template v-if="!!item.refresh_time">刷新时间:{{ item.show_time }}</template>
        <template v-else>发布时间:{{ item.show_time }}</template>
      </div>
      <div class="btn_wrap" v-if="item.status == 5" @click="editUrgent">
        <div class="btn">立即修改</div>
      </div>
      <button class="st-right" type="default" data-name="shareBtn" :open-type="'share'" v-if="item.status == 1">去分享</button>
    </div>
    <!-- 展示中 -->
    <div class="zsz_btg" v-if="item.status == 1 || item.status == 3">
      <div class="zsz_left">
        <div class="now" @click="updateStatus(1)" :class="[item.status == 1 && 'zsz_active']">正在求职</div>
        <div class="no" @click="updateStatus(3)" :class="[item.status == 3 && 'zsz_active']">暂不求职</div>
      </div>
      <div class="zsz_right">
        <div class="edit" @click="editUrgent" v-if="item.status == 1 || item.status == 3 || item.status == 5">
          <i class="icon"></i>
          <text>修改</text>
        </div>
      </div>
    </div>
    <!-- 审核不通过 -->
    <div class="btg" v-if="item.status == 5">
      <div class="desc">不通过原因：{{ item.fail_reason }}</div>
    </div>
  </div>
</template>

<script>
export default {
  name: "regulateResumeItem",
  props: {
    item: {
      type: Object,
      default: null,
    },
  },
  methods: {
    editUrgent() {
      this.$redirectTo("/pages2/postRecruitmentInformation", { id: this.item.id });
    },
    preview(index) {
      uni.previewImage({
        current: index,
        urls: this.data["photo_urls"],
      });
    },
    getImages(str) {
      return str.split(",");
    },
    async updateStatus(status) {
      if (status == this.item.status) {
        return;
      }
      let params = {
        id: this.item.id,
        status: status,
      };
      // status 1、生效， 2、删除，3、暂停，4、待审核，5、审核拒绝
      let res = await this.$http.requestSync("/resumes/update_status", params);
      if (res.code == 200) {
        this.$emit("update");
      }
    },
    toDetail() {
      if (this.item.status == 4) {
        return;
      }
      this.$togo("/pages2/resumeDetail", { id: this.item.id });
    },
  },
};
</script>

<style lang="scss" scoped>
.regulateResumeItem {
  margin-bottom: 20px;
  .wrap {
    width: 100%;
    background: #fdfafa;
    border-radius: 10px 10px 10px 10px;
    opacity: 1;
    border: 1px solid #ffd5d5;
    margin: 0 auto;
    margin-bottom: 15px;
    min-height: 50px;
    box-sizing: border-box;
    padding-bottom: 4px;
    .top {
      position: relative;
      display: flex;
      justify-content: space-between;
      align-content: center;
      height: 30px;
      .image {
        width: 65px;
        height: 30px !important;
        margin-left: -7px;
        margin-top: 1px;
      }
      .isjj {
        font-size: 11px;
        font-family: PingFang SC-Regular, PingFang SC;
        font-weight: 400;
        color: #ff8822;
        line-height: 30px;
        margin-right: 6px;
      }
      .is_urgent {
        position: absolute;
        top: -2px;
        right: -2px;
        width: 36px;
        height: 36px;
      }
    }
    .title {
      box-sizing: border-box;
      padding: 0 10px;
      font-size: 16px;
      font-family: PingFang SC-Semibold, PingFang SC;
      font-weight: 600;
      color: #333333;
      margin: 7px auto 10px;
      @include ells(2);
    }
    .content {
      box-sizing: border-box;
      padding: 0 10px;
      font-size: 13px;
      font-family: PingFang SC-Regular, PingFang SC;
      font-weight: 400;
      color: #555555;
      margin-bottom: 10px;
      @include ells(3);
    }
    .image_box {
      width: 100%;
      box-sizing: border-box;
      padding: 0 10px;
      display: flex;
      margin-bottom: 10px;
      image {
        width: 76px;
        height: 76px;
        border-radius: 6px;
        margin-right: 9px;
        flex-shrink: 0;
      }
      image:last-child {
        margin-right: 0px;
      }
    }
    .line {
      width: 93%;
      margin: 0 auto;
      height: 1px;
      background: #e4e4e4;
      margin-bottom: 10px;
    }
    .bottom {
      display: flex;
      align-items: center;
      box-sizing: border-box;
      padding: 0 10px;
      margin-bottom: 11px;
      .item {
        font-size: 11px;
        font-family: PingFang SC-Regular, PingFang SC;
        font-weight: 400;
        color: #999999;
        display: flex;
        align-items: center;
        margin-right: 11px;
        position: relative;
        .iconfont {
          font-size: 12px;
        }
        &::after {
          content: "";
          width: 1px;
          height: 10px;
          background: #e4e4e4;
          position: absolute;
          right: -6px;
        }
      }
      .item:last-child:after {
        display: none;
      }
    }
  }
  .btg {
    .desc {
      height: 36px;
      font-size: 13px;
      font-family: PingFang SC-Regular, PingFang SC;
      font-weight: 400;
      color: #f54a4a;
      margin: 10px 0;
    }
  }
  .btn_wrap {
    // width: 100%;
    display: flex;
    justify-content: flex-end;
    .btn {
      text-align: center;
      line-height: 27px;
      width: 76px;
      height: 27px;
      background: #ff8822;
      border-radius: 14px 14px 14px 14px;
      font-size: 12px;
      font-family: PingFang SC-Semibold, PingFang SC;
      font-weight: 600;
      color: #ffffff;
    }
  }
  .show-time {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    .st-left {
      color: #999999;
      font-size: 12px;
    }
    .st-right {
      width: 80px;
      height: 28px;
      margin: 0;
      padding: 0;
      display: flex;
      align-items: center;
      justify-content: center;
      background: #ff8822;
      border-radius: 14px;
      color: #fff;
      font-size: 12px;
      transition: all 0.5s ease;
    }
  }
  .zsz_btg {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 0 auto;
    margin-bottom: 15px;
    .zsz_left {
      display: flex;
      align-content: center;
      text-align: center;
      width: 132px;
      height: 27px;
      background: #efefef;
      border-radius: 14px 14px 14px 14px;
      line-height: 27px;
      font-size: 12px;
      font-family: PingFang SC-Regular, PingFang SC;
      font-weight: 400;
      color: #999999;
      .now {
        width: 66px;
        height: 27px;
      }
      .no {
        width: 66px;
        height: 27px;
        border-radius: 14px 14px 14px 14px;
      }
      .zsz_active {
        background: #ff8822;
        border-radius: 14px 14px 14px 14px;
        color: #fff;
        transition: all 0.5s ease;
      }
    }
    .zsz_right {
      display: flex;
      align-items: center;
      .edit {
        display: flex;
        align-items: center;
        flex-shrink: 0;
        .icon {
          width: 20px;
          height: 20px;
          background: url("@/pages2/static/images/bj.png");
          background-position: center;
          background-size: 100%;
          background-repeat: no-repeat;
          margin-right: 3px;
        }
        text {
          font-size: 14px;
          font-family: PingFang SC-Regular, PingFang SC;
          font-weight: 400;
          color: #ff8822;
        }
      }
    }
  }
}
</style>
